﻿/// <summary>
/// 功能：
/// 作者：chao.jiang
/// 日期：2012/8/9 17:47:40
/// 备注：
/// 修改：
/// </summary>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Phoenix.Common.Util
{
   public static class Cookie
    {

        #region Cookie操作与加密

        /// <summary>
        /// 保存字串为cookie
        /// </summary>
        /// <param name="key">键值</param>
        /// <param name="value">字串</param>
        /// <param name="standalone">是否是独立域名<c>true</c>为独立域名，否则合并到用户票据Cookie.</param>
        public static void SetCookie(string key, string value,string domain)
        {
            
            
                HttpContext.Current.Response.Cookies[key].Value = value;
                HttpContext.Current.Response.Cookies[key].Domain = domain;
                HttpContext.Current.Response.Cookies[key].Expires = DateTime.Now.AddYears(1);

        }


        public static string GetCookie(string Key)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[Key];
            if (cookie != null)
            {
                try
                {
                    return cookie.Value;
                }
                catch
                {
                    return string.Empty;
                }
            }
            else
                return string.Empty;
        }



        #endregion
    }
}
